<?php defined ( 'SYSPATH' ) or die ( 'No direct script access.' );
/**
 * Site block class
 * 
 * @author cks
 */
class Block_Site {
	/**
	 * 公共头部块
	 */
	public static function header() {

		if(Lib_Base::is_mobile()){

			$view = View::factory ('mobile/site/header');
			
		}
		else{

			$view = View::factory ('template/header');

			$assort_list = Cache::instance()->get('assort_list', null);

			if(empty($assort_list)){

				$model_assort=new Model_Assort();

            	$assort_list=$model_assort->getInfo();

            	Cache::instance()->set('assort_list', $assort_list, 30000);

			}

			
            $view->assort_list=$assort_list;

		}
		
		return $view;
	}
	/**
	 * 公共固定底部
	 */
	public static function footer() {
		
		if(Lib_Base::is_mobile()){

			$view = View::factory ('mobile/site/footer');

		}
		else{

			$view = View::factory ('site/block/footer');
		}
		
		return $view;
	}

	public static function search() {

		if(Lib_Base::is_mobile()){

			$view = View::factory ('mobile/site/search');

		}
		else{

			$view = View::factory ('/site/block/search');
		}
		
		return $view;
	}

	public static function quickLogin() {

		$view = View::factory ('/site/block/quickLogin');
		
		return $view;
	}

	public static function aside(){

		$c_cache= Cache::instance();

        $model=new Model_Site();

        $newPost = $c_cache->get('newPost', null);

        if(empty($newPost)){

        	$newPost=$model->getNewPost();

        	$c_cache->set('newPost', $newPost, 300);

        }

        $hotPost = $c_cache->get('hotPost', null);

        if(empty($hotPost)){

        	$hotPost=$model->getHotPost();

        	$c_cache->set('hotPost', $hotPost, 300);

        }

        $recommendPost = Cache::instance()->get('recommendPost', null);

        if(empty($recommendPost)){

        	$recommendPost=$model->getRecommendPost();

        	$c_cache->set('recommendPost', $recommendPost, 300);

        }

        $view = View::factory ('/template/aside');

        $view->newPost=$newPost;

        $view->hotPost=$hotPost;

        $view->recommendPost=$recommendPost;
		
		return $view;
	}

}